package 力扣;
//给出一个完全二叉树，求出该树的节点个数。
public class 完全二叉树的节点个数 {
    public static void main(String[] args) {

    }
    public static class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
    }
    public static int countNodes(TreeNode root) {
          int count=0;
          if (root==null)
              return 0;
          if (root!=null)
              count+=1;
          if(root.left!=null)
              count+=countNodes(root.left);
          if (root.right!=null)
              count+=countNodes(root.right);
          return count;
    }
}
